<template>
  <Header title="地址管理" />
  <div class="address-page">
    <!-- 地址列表 -->
    <van-address-list
      v-model="chosenAddressId"
      :list="addressList"
      :disabled-list="disabledList"
      disabled-text="以下地址超出配送范围"
      default-tag-text="默认"
      @add="add()"
      @edit="onEdit"
    />
  </div>

</template>

<script setup>
import { ref, reactive ,computed } from "vue";
import Header from "@/components/Header.vue";
import { userStore } from "@/store/UserStore";
import { useRouter } from "vue-router";

const store = userStore();
const router = useRouter();

// 地址数据
const addressList = store.addressList;

const disabledList = store.disabledList;

// const chosenAddressId = computed(() => {
//   return store.addressList = forEach((item)=>{
//     if(item.isDefault){
//       return item.id
//     }
//   })
// })

function add() {
  router.push({
    path: "/addressEdit",
    query: {
      type: "add"
    }
  });
}

const onEdit = (content) =>{
  router.push({
    path: "/addressEdit",
    query: {
      id:content.id,
      type: "edit"
    }
  });
  }

</script>

<style lang="less">

</style>

